package com.my.study.designPatterns.combinationPattern;

import com.my.study.designPatterns.iterator_combination.NullIterator;

import java.util.Iterator;

/**
 * 具体单个子菜单， 菜单项
 */
public class MenuItem extends MenuComponent {

    private String name;
    private String description;
    private Boolean vegetatian;
    private Double price;

    public MenuItem(String name, String description, Boolean vegetatian, Double price) {
        this.name = name;
        this.description = description;
        this.vegetatian = vegetatian;
        this.price = price;
    }

    @Override
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean getVegetatian() {
        return vegetatian;
    }

    public void setVegetatian(Boolean vegetatian) {
        this.vegetatian = vegetatian;
    }

    @Override
    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    @Override
    public Boolean isVegetarian() {
        return vegetatian;
    }

    public void print(){
        System.out.print("   " + getName());
        if(isVegetarian()){
            System.out.print("(v)");
        }
        System.out.println("," + getPrice());
        System.out.println("    ----- " + getDescription());
    }

    @Override
    public Iterator createIterator() {

        return new NullIterator();
    }
}
